﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Hotnet.Entity.Picture[]>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">    
	<%
		
		PictureCategory category = ViewData["Category"] as PictureCategory;
		PictureGroup group = ViewData["Group"] as PictureGroup;
		
	%>
	图片列表 - <%=group.Name %> - <%=category.Name %> - 图片管理 - Hotent后台管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<%
		
		PictureCategory category = ViewData["Category"] as PictureCategory;
		PictureGroup group = ViewData["Group"] as PictureGroup;
		
	%>
	
	
	<div class="b1 m3">
		<h2 class="m5">
			<%=category.Name %> - <%=group.Name %>
		</h2>
	</div>
	
	<div class="p5 m5">
		<div class="fl">
			<%=Html.ActionLink("返回" + category.Name + "分类", "Index","AdminPictureCategory", new { id = category.CategoryID }, null)%>
		</div>
		<div class="fr">
			<%=Html.ActionLink("批量编辑", "EditBatch", "AdminPicture", new { categoryId = category.CategoryID, groupId = group.GroupID }, null)%> | 
			<%= Html.ActionLink("上传图片", "UploadImage", "AdminPicture",  new { categoryID = category.CategoryID, groupID = group.GroupID }, null)%></div>
		<div class="cb"></div>
	</div>
	<p class="tar m5">
	</p>
	<div  class="b1 p5 ma tac" style="width:99%">
		<%if (Model == null || Model.Length == 0){%>
			<div class="tac" style="margin:50px;Color:Red;font-size:20px">
				没有图片
			</div>
		<%} else { %>
			<% foreach (var item in Model) { %>
				<div class="fl m3 tac">
					<a href="<%=Hotnet.Biz.Properties.Settings.Default.UploadFolder + item.LocalPath %>" rel="lytebox[vacation]" class="b1 hb1 dbk" title="<%=Html.Encode(item.Description)%>"><img class="m5" style="border:0;width:160px; height:120px" src="<%=Hotnet.Biz.Properties.Settings.Default.UploadFolder + item.ThumbnailPath%>" /></a>
					<div class="m5">
						<a href="javascript:void(0);" onclick="javascript:UpdateGroupCoverImage(this, <%=item.PictureID %>);" id="pic<%=item.PictureID%>" >设为封面</a> 
						<span style="display:none;" id="cover<%=item.PictureID%>"><span style="color:red;">我是封面</span></span>
						<a href="/AdminPicture/PictureCrop?pictureid=<%=item.PictureID %>">编辑图片</a>
						| <a href="javascript:editPicture(<%=item.PictureID %>)">编辑</a>
						| <a href="javascript:confirmDelete('确定要删除该图片?', '/AdminPicture/Delete/', <%=item.PictureID %>);">删除</a> |
					</div>
				</div>
			<% } %>
		<%}%>
		<div class="cb">&nbsp;</div>
	</div>
	
	<div class="p5 m5">
		<%=Html.ActionLink("返回" + category.Name + "系列", "Index", "AdminPictureCategory", new { id = category.CategoryID }, null)%> |
			<a href="javascript:editGroup(<%=group.GroupID %>);">编辑</a>|
			<a href="javascript:confirmDelete('注意:该操作将删除该系图片组中所有图片.确定删除?', '/AdminPictureGroup/Delete/', <%=group.GroupID %>);" >删除</a>
	</div>
	<div id="editGroupWin" class="dn">
		<%using (Html.BeginForm("InnerEdit", "AdminPictureGroup")){%>
			<input type="hidden" id="groupId" name="groupId"/>
			<input type="hidden" name="categoryId" id="categoryId2" />
			<table style="margin:auto" class="list" width="100%">
				<tr>
					<td style="width:35%" align="right">图片组名称:</td>
					<td><input type="text" id="groupName" name="name" /></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组描述:</td>
					<td><textarea cols="23" rows="5" id="groupDescription" name="description" ></textarea></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组排序:</td>
					<td><input type="text" id="orderInCategory" name="orderInCategory" /></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组来源:</td>
					<td><%=Html.DropDownList("sourceFromID", ViewData["SourceFromList"] as IEnumerable<SelectListItem>, "==请选择==", new { style = "width:170px;" })%></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组Tag:</td>
					<td><input type="text" id="tags" name="tags" /></td>
				</tr>
				<tr align="center">
					<td colspan="2"><input type="submit" value="确定" class="ml3 boxy-button"/><input type="button" value="关闭" onclick="closeGroupWin();" class="ml3 boxy-button"/></td>
				</tr>
			</table>
		<% } %>
	</div>
	<div id="editPictureWin" class="dn">
		<%using (Html.BeginForm("Edit", "AdminPicture")){%>
		<input type="hidden" name="pictureId" id="pictureId" />
		<input type="hidden" id="groudId2" name="groupId"/>
		<div class="b1">
			<div class="b2b fl m3 tac" style="width: 185px; height: 185px;">
				<img id="thumbnailPath" alt="" class="m3" style="border: 0; width: 180px; height: 180px" src="" />
			</div>
			<div class="fl m5">
				<div>
					<span>图片说明:</span>
					<textarea name="description" id="description" cols="0" rows="0" style="width: 300px; height: 140px;"></textarea>
				</div>
				<div>
					<span>组内顺序:</span>
					<input type="text" name="orderInGroup" id="orderInGroup" style="width: 25px; height: 20px;" />
				</div>
			</div>
			<div class="cb">
			</div>
		</div>
		<div class="tac m5">
			<input class="boxy-button" type="submit" value="保存"/>
			<input type="button" value="关闭" onclick="closePictureWin()" class="ml3 boxy-button"/>
		</div>
		<% } %>
	</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">    
	<%PictureGroup group = ViewData["Group"] as PictureGroup;%>
	<script type="text/javascript">
		var b_editGroupWin = null;
		function editGroup(t_groupId){
			$.getJSON("/AdminPictureGroup/Get/" + t_groupId + "/?" + new Date(), function(group)
			{
				$("#groupId").val(t_groupId);
				$("#groupName").val(group.Name == null ? "" : group.Name);
				$("#groupDescription").val(group.Description == null ? "" : group.Description);
				$("#orderInCategory").val(group.OrderInCategory);
				$("#categoryId2").val(group.CategoryID);
				$("#sourceFromID").val(group.SourceFromID);
				$("#tags").val(group.Tags == null ? "" : group.Tags);
				if (b_editGroupWin == null)
					b_editGroupWin = new Boxy($('#editGroupWin'), { modal: false, title: '编辑图片组', closeText: '[×]', draggable: true }).resize(400, 270);
				else
					b_editGroupWin.show();
			});
		}
		
		function closeGroupWin(){
			if(b_editGroupWin != null) b_editGroupWin.hide();
		}

		var b_editPictureWin = null;
		function editPicture(pictureId) {
			$.getJSON("/AdminPicture/Get/"+pictureId + "/?" + new Date(), function(pic){
				$("#pictureId").val(pictureId);
				$("#groudId2").val(pic.GroupID);
				$("#orderInGroup").val(pic.OrderInGroup?pic.OrderInGroup:"0");
				$("#description").val(pic.Description == null ? "" : pic.Description);
				$("#thumbnailPath").attr("src", "<%=Hotnet.Biz.Properties.Settings.Default.UploadFolder %>" + pic.ThumbnailPath);
				if (b_editPictureWin == null) {
					b_editPictureWin = new Boxy($('#editPictureWin'), { modal: false, title: '编辑图片', closeText: '[×]', draggable: true }).resize(600, 240);
				}
				else
					b_editPictureWin.show();
			});
		}

		function closePictureWin(){
			if(b_editPictureWin != null) b_editPictureWin.hide();
		}
		var s_CoverImageID = null;
		var s_SpanText = null;
		
		$(function()
		{
			<%if(group.CoverImageID!=null||group.CoverImageID!=0) {%>
			s_CoverImageID = document.getElementById("pic<%=group.CoverImageID%>");
			s_CoverImageID.style.cssText = "display:none";
			s_SpanText = document.getElementById("cover<%=group.CoverImageID%>")
			s_SpanText.style.cssText = "";
			<%} %>
		});
		
		function UpdateGroupCoverImage(myself, pictureId){
			$.ajax(
			{
				url:"/AdminPicture/SetGroupCoverImage/", 
				data:"groupId=<%=group.GroupID %>&pictureId=" + pictureId, 
				type : "post",
				async : true,
				success : function(msg)
				{
					if(s_CoverImageID != null){
						s_CoverImageID.style.cssText = "";
						s_SpanText.style.cssText = "display:none";
					}
					
					myself.style.cssText = "display:none";
					s_SpanText = document.getElementById("cover" + pictureId);
					s_SpanText.style.cssText = "";
					s_CoverImageID = myself;
				}
			});
		}
		
	</script>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>

